#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>

int* selfDividingNumbers(int left, int right, int* returnSize) {
    int* arr = (int*)malloc(sizeof(int) * (right - left));
    int i = left;
    int x = 0;
    for (; i <= right; i++)
    {
        int count = 1;
        int tmp = i;
        while (tmp)
        {
            int cmp = tmp % 10;
            if (cmp == 0)
            {
                count = 0;
                break;
            }
            if (i % cmp != 0)
            {
                count = 0;
                break;
            }
            tmp /= 10;
        }
        if (count == 1)
        {
            arr[x] = i;
            x++;
        }
    }
    *returnSize = x;
    return arr;
}

int main()
{
    int n = 0;
    int i = 0;
    int* arr = selfDividingNumbers(1, 22, &n);
    for (i = 0; i < n; i++)
    {
        printf("%d ", arr[i]);
    }
    return 0;
}